import AppTypeEnum from "./utils/AppTypeEnum";

/**
 * @author 赵京涛
 * @descriptions: 项目配置
 */
const { VITE_SCYF_APP_VERSION } = import.meta.env;

/**
 * 荣佳润旗舰店版本号
 */
export const RJR_SCYF_APP_VERSION = VITE_SCYF_APP_VERSION;

/**
 * token
 */
export const tokenUrl = "jyfwyun.com|127|192|theling";

export const appIdObj: any = {
  [AppTypeEnum.QWD_MP_110107006]: "ded598b1c77f924d302aadebbe341601",
  [AppTypeEnum.SJSKW_MP]: "bd77c9ca9aadeaf6133571de6d89795d",
  [AppTypeEnum.QWD_WAPP]: "7ba1799ca44a4c24a8e558937be02bb1",
};

export const AppTypes = [
  AppTypeEnum.SJSKW_MP,
  AppTypeEnum.QWD_WAPP,
  AppTypeEnum.QWD_MP,
  AppTypeEnum.QWD_GL,
  AppTypeEnum.QWD_MP_110107006,
];
export const AppNames = [
  "石景山科委公众号",
  "企业问答小程序",
  "企业问答公众号",
  "企业问答 - 管理端",
  "金顶街企业服务",
  "精致宠物荣佳润旗舰店公众号",
];
export const nameRules = ["赵京涛", "赵盖", "杨培宙", "游客"];
export const getAppObj = (): {
  name: string;
  value: AppTypeEnum;
  key: number;
} => ({
  name: AppNames[ZL_APP_TYPE],
  value: AppTypes[ZL_APP_TYPE],
  key: ZL_APP_TYPE,
});

export const getNameRules = () => {
  return { name: nameRules[RJR_NAME_ROLUES] };
};

// 回调的前缀
export const redirectUriPrefix =
  process.env.NODE_ENV === "development" ? "http" : "https";

// 配置微信登录的appId和回调地址
export const getWxMpLoginUrl = (redirectUrl: string) => {
  const appType = getAppObj().value;
  let appId = "";
  let redirectUri = "";
  switch (appType) {
    case AppTypeEnum.SJSKW_MP:
      appId = "wxc6d95fd1ec0989ca";
      redirectUri = `${redirectUriPrefix}://sjskw.jyfwyun.com/pages/user/login?redirectUrl=${redirectUrl}`;
      break;
    case AppTypeEnum.QWD_MP:
      appId = "wxc6d95fd1ec0989ca";
      redirectUri = `${redirectUriPrefix}://qwd.jyfwyun.com/pages/user/login?redirectUrl=${redirectUrl}`;
      break;
    default:
      appId = "wxc6d95fd1ec0989ca";
      redirectUri = `${redirectUriPrefix}://qwd.jyfwyun.com/pages/user/login?redirectUrl=${redirectUrl}`;
      break;
  }
  return `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`;
};
const jyfwIpObj = {
  https: "https://api.jyfwyun.com/",
  ylb: "http://theling.top:9002/",
  dev: "http://192.168.1.190:8222/",
  zqf: "http://192.168.1.128:9000/",
};
export const API_URL = process.env.NODE_ENV === "development" ? jyfwIpObj.https : jyfwIpObj.https;
